<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>GEN24</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN23.html" title="GEN23" />
    <link rel="next" href="GEN25.html" title="GEN25" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN24</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN23.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN25.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="GEN24"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN24" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN24</span>
        </h2>
        <p>GEN24 — 
      Reads numeric values from another allocated function-table and rescales them.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215190496"></a>
        <h2>Description</h2>
        <p>
      This subroutine reads numeric values from another allocated function-table and rescales them according to the max and min values given by the user.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215191824"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size -24 ftable min max</pre>
      </div>
      <div class="refsect1">
        <a id="idp215193712"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>#, time, size</em></span> -- the usual GEN parameters. See <a class="link" href="f.html" title="f Statement (or Function Table Statement)">f statement</a>.
    </p>
        <p>
      <span class="emphasis"><em>ftable</em></span> -- ftable must be an already allocated table with the same size as this function.
    </p>
        <p>
      <span class="emphasis"><em>min, max</em></span> -- the rescaling range.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        This GEN is useful, for example, to eliminate the starting offset in exponential segments allowing a
real starting from zero.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp215199152"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GEN24 opcode. It uses the file <a class="ulink" href="examples/gen24.csd" target="_top"><em class="citetitle">gen24.csd</em></a>.
           </p>
        <div class="example">
          <a id="idp215200928"></a>
          <p class="title">
            <strong>Example 1113. Example of the GEN24 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o gen24.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1

ifn  <span class="op">=</span> p4				<span class="comment">;choose between tables</span>
kcps <span class="opc">init</span> 1<span class="op">/</span>p3				<span class="comment">;create index over duration of note.</span>
kndx <span class="opc">phasor</span> kcps
ixmode <span class="op">=</span> 1				<span class="comment">;normalize to 0-1</span>
kval <span class="opc">table</span> kndx, ifn, ixmode
asig <span class="opc">poscil</span> .7, 440 <span class="op">+</span> kval, 1		<span class="comment">;add to frequency</span>
     <span class="opc">outs</span> asig, asig
  
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 16384 10 1	<span class="comment">;sine wave</span>
<span class="stamnt">f</span> 10 0 16384 -24 1 0 400<span class="comment">;scale sine wave from table 1 from 0 to 400</span>
<span class="stamnt">f</span> 11 0 16384 -24 1 0 50	<span class="comment">;and from 0 to 50</span>

<span class="stamnt">i</span> 1 0 3 10
<span class="stamnt">i</span> 1 4 3 11
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />  
    </p>
      </div>
      <div class="refsect1">
        <a id="idp215205216"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in Csound version 4.16</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN23.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN25.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN23 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN25</td>
        </tr>
      </table>
    </div>
  </body>
</html>
